#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<errno.h>
#include<fcntl.h>
#include<unistd.h> 
#include<sys/wait.h>
#include<sys/types.h>
#include<pthread.h>

int main(int argc, char* args[])
{
	int i = 1;
	bool is_parent = true;
	printf("this is 0th\n");

	for(; i <= 5 && is_parent; i++){
		pid_t pd = fork();
		if(pd){
			is_parent = true;
			wait(0);
		}
		else {
			is_parent = false;
		}
	}

	if(!is_parent){
		printf("this is %dth\n", i - 1);
	}

	exit(0);

}
